package Servlet;

import service.OrgnazitionService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet(urlPatterns = "/OrgnazitionStatus")
public class OrgnazitionStatus extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        OrgnazitionService orgnazitionService=new OrgnazitionService();
        int id= Integer.parseInt(request.getParameter("id"));
        int status= Integer.parseInt(request.getParameter("status"));
        if (status==0){
            status=1;
        }else {
            status=0;
        }
        int i=orgnazitionService.CardStatus(id,status);
        if (i>0){
            response.sendRedirect(request.getContextPath()+"/OrgnazitonServlet");
        }
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req,resp);
    }
}
